package com.train.daemonThread;

/**
 * 守护线程：其他线程执行完毕后，守护线程也结束运行
 * 守护线程默认是关闭的，在start前对thread设置：调用{@link Thread#setDaemon(boolean)}方法，设置值为{@link Boolean#TRUE}
 * 运行：调用{@link Thread#start()}方法启动线程
 * */
public class RunThread {
    public static void main(String[] args) {
        Thread daemonThread = new Thread(new DaemonThread());
        daemonThread.setDaemon(Boolean.TRUE);
        daemonThread.start();
        for (int i = 0; i < 10; i++) {
            System.out.println("主线程，我正在执行第："+i+"次");
        }
    }
}